<?php

function top(){
  $log = "";
  if( User_Session::getUserName() != "" ){
    $log = "<td width=\"15%\" style=\"background-color:#bbbbdd\">".__('Jesteś zalogowany jako').": <br><b>".User_Session::getUserName()."</b>.<br><br>";
	$log .="<div style='margin-bottom:5px;'>".__('Wybierz język').":<br>";
    
	$_SESSION['url_temp']=$_SERVER['QUERY_STRING'];
	$countries=Translate::getallcountries();
	$lang=Translate::getlanguage();
	foreach($countries as $country){
		if($lang==$country['code'])
			$log .="<a style='color:Red' href='index.php?action=languages&site=change&lang=".$country['country']."&Wybierz=Wybierz'>-".$country['code']."-&nbsp</a>";
		else 
			$log .="<a href='index.php?action=languages&site=change&lang=".$country['country']."&Wybierz=Wybierz'>-".$country['code']."-&nbsp</a>";
	}
	$log .='<div id="dialog" style="display:none" title="Basic dialog"><input style="width:265px;height:40px" id="area"></div>';
        $eventModule = Module::init('events');
        $conf = $eventModule->loadConfig('events');
        $usersString = trim($conf['debug_users']);
        $usersArray = array();
        if (!empty($usersString))
        {
            $usersArray = explode(',', $usersString);            
        }
        
 
	if ( empty($usersArray) || ( !empty($usersArray) && in_array(User_Session::getUserId(), $usersArray)) ) {
            $log .="</div><div class='ui-state-highlight ui-corner-all' style='z-index:2;position:fixed;margin-top:-165px;margin-left:80px;width:930px;background-color:Gray;height:75px' id='plan'>Plan dnia</div>";
            $log .="<div class='ui-state-highlight ui-corner-all' onclick='show_plan()' style='z-index:2;cursor: pointer;position:fixed;margin-top:-90px;margin-left:80px;width:140px;background-color:Gray;height:25px' id='plan_name'> Otwórz plan dnia</div>";
        	$log .="<div  id='blink' class='ui-state-highlight ui-corner-all' style='display:none;z-index:2;cursor: pointer;position:fixed;margin-top:-90px;margin-left:365px;color:Red;height:25px'></div>";  
            
	} 
  
  $path = '../pgb_files/ranking_files/';
  if (file_exists($path.'rank.html')) {
    if ($_COOKIE["show_rank"]=='hide') {
      $log .= "<div style='z-index:2;position:fixed;top:0px;margin-top:25px;top:-477px;left:0px;margin-left:0px;height:436px;' id='rank'>";
      $log .= file_get_contents($path.'rank.html'); 
      $log .= "</div><div onclick='show_rank()' class='ui-corner-all' style='cursor: pointer;position:fixed;top:0px;left:0px;margin-left:0px;width:140px;background-color:#99aaff;height:25px;border: 1px solid black; border-collapse: collapse;' id='rank_name'>Pokaż ranking</div>"; 
    } else {
      $log .= "<div style='z-index:2;position:fixed;top:0px;margin-top:25px;top:0px;left:0px;margin-left:0px;height:435px;' id='rank'>";
      $log .= file_get_contents($path.'rank.html'); 
      $log .= "</div><div onclick='show_rank()' class='ui-corner-all' style='cursor: pointer;position:fixed;top:0px;left:0px;margin-left:0px;width:140px;background-color:#99aaff;height:25px;border: 1px solid black; border-collapse: collapse;' id='rank_name'>Ukryj ranking</div>";
    }
  }
       
	  $log .='<input id="rights" type="hidden" value="'.User_Session::getUserRights().'" >';
        
    //$tip_status=HelpActionManager::get_tipstatus();
    //$tip=$_SESSION['tipstatus'];
    //$log .='<br><input id="tip" type="hidden" value="'.$tip.'"><a onclick="change_status()" href="">'.$tip_status.'</a><br>';
	
    //sprawdz uprawnienie do zmiany tozsamosci
    if(User_Session::getUserRights() == 3 || User_Session::getRealUserId()) {
      if(User_Session::getRealUserId()) {
        $log .= "<a href=\"index.php?action=swichuser&go=oryginal\">".__('Przywróc oryginalnego użytkownika')."</a><br><br>";
      }
      else {
        $log .= "<a href=\"index.php?action=swichuser&go=choose\">".__('Zmień użytkownika')."</a><br><br>";
      }
    }
    $log.= "<button onClick=\"javascript:goToURL('index.php?action=logout')\" class=\"button\">".__('Wyloguj')."</button></td>";
  }
  return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
  <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>'.Config::get('settings.site.name').'</title>
          <link rel="stylesheet" href="css/styl.css" type="text/css" />
                <link rel="stylesheet" href="css/menus.css" type="text/css" />
                <link rel="stylesheet" href="css/layout.css" type="text/css" />
                <link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
                <script src="js/jquery.min.js" type="text/javascript"></script>
                <script src="js/jquery-ui.min.js" type="text/javascript"></script>
                <script src="js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
                <script src="js/ajax_core.js" type="text/javascript"></script>
                <script src="js/jsDate.js" type="text/javascript"></script>
                <script src="js/kalendarz.js" type="text/javascript"></script>
                <script src="js/jQuerys.js" type="text/javascript"></script>
                <script src="js/Application.php.js" type="text/javascript"></script>
                <script src="js/html.js" type="text/javascript"></script>
                <script src="js/php.min.js" type="text/javascript"></script>
                
                <script src="js/interval_functions.js" type="text/javascript"></script>
                
                '.(User_Session::getUserName() != "" ? Application::getExternalModuleCsses()." ".Application::getExternalModuleJses()." ".Application::getModuleCsses().Application::getModuleJses():"").'
  </head>

  <body>
  <center><table width="80%">
  <tr align="center">'.$log.'<td width="90%" style="background-color:#bbbbdd">
    <center><h1>'.__(Config::get('settings.site.name')).'</h1></center>
        </td> </tr> ';
}

function top2(){
  $log = "";



  return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
  <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>TESTY</title>
          <link rel="stylesheet" href="css/styl.css" type="text/css" />
                <link rel="stylesheet" href="css/menus.css" type="text/css" />
                <link rel="stylesheet" href="css/layout.css" type="text/css" />
                <link rel="stylesheet" href="css/jquery_ui_1.8.14.custom.css" type="text/css" />
                <script src="js/jquery.min.js" type="text/javascript"></script>
                  <script src="js/jquery_ui.min.js" type="text/javascript"></script>
                <script src="js/jsDate.js" type="text/javascript"></script>
                <script src="js/Application.php.js" type="text/javascript"></script>
                <script src="js/kalendarz.js" type="text/javascript"></script>
                <script src="js/html.js" type="text/javascript"></script>
                <script src="js/php.min.js" type="text/javascript"></script>
                '.Application::getModuleCsses().Application::getModuleJses().'
  </head>

  <body>
  <center><table width="80%">
  <tr align="center">'.$log.'<td width="90%" style="background-color:#bbbbdd">
    <center><h1>'.__('Testy/Ankiety').'</h1></center>
        </td> </tr> ';
}

function frame($menu, $form)
{
  $frame ="

  <tr> <td  width='15%' height='400px' valign='top' style='background-color:#bbbbdd'><br />
    <center><table  width='100%'><tr> <td id='mainMenu'>
       ".$menu."
       </td> </tr> </table></center>
  </td>

  <td valign='top'> <center><br /> <br /><table  width='100%'>
  <tr> <td><center>

    ".$form."</center></td> </tr>  </table></center>
  </td>
  </tr>";

  return $frame;
}


function frame_bezmenu($form)
{
  $frame = "<tr><td valign='top'> <center><br /> <br /><table  width='100%'>
  <tr> <td style='background-color:#CCCCCC'><center>

    ".$form."</center></td> </tr>  </table></center>
  </td>
  </tr>";

  return $frame;
}


function bottom()
{
  $bottom ="
  </table>
  </center>

  </body>
  </html>";

  return $bottom;
}
